package com.gomore.opple.data.local;

import android.content.Context;
import android.text.TextUtils;

import com.gomore.opple.rest.employee.LoginResult;
import com.gomore.opple.utils.JacksonUtils;
import com.gomore.opple.web.cgform.consumer.entity.TOConsumerEntity;

import java.util.List;

import javax.inject.Singleton;

@Singleton
public class LocalDataRepository implements LocalDataSource {

    private PreferencesApi mPreferencesApi;

    public LocalDataRepository(Context context) {
        mPreferencesApi = PreferencesManager.getInstance(context);
    }

    /**
     * @param userName
     */
    @Override
    public void saveUserName(String userName) {
        mPreferencesApi.saveUserName(userName);
    }

    /**
     * @return
     */
    @Override
    public String getUserName() {
        return mPreferencesApi.getUserName();
    }

    @Override
    public void saveConsumer(TOConsumerEntity toConsumerEntity) {
        mPreferencesApi.saveConsumer(toConsumerEntity);
    }

    @Override
    public void clearConsumer() {
        mPreferencesApi.clearConsumer();
    }

    @Override
    public TOConsumerEntity getConsumer() {
        return mPreferencesApi.getConsumer();
    }

    /**
     * @param passWord
     */
    @Override
    public void savePassWord(String passWord) {
        mPreferencesApi.savePassWord(passWord);
    }

    /**
     * @return
     */
    @Override
    public String getPassWord() {
        return mPreferencesApi.getPassWord();
    }

    @Override
    public void saveAppVersion(String version) {
        mPreferencesApi.saveAppVersion(version);
    }

    @Override
    public String getAppVersion() {
        return mPreferencesApi.getAppVersion();
    }

    /**
     * 保存用户信息
     */
    @Override
    public void saveUser(LoginResult user) {
        mPreferencesApi.saveUser(user);
    }

    /**
     * 获取用户信息
     */
    @Override
    public LoginResult getUser() {
        return mPreferencesApi.getUser();
    }

    @Override
    public void clearMessage() {
        mPreferencesApi.clearMessage();
    }

    /**
     * 获取搜索关键字
     *
     * @return
     */

    @Override
    public List<String> getSearchKey() {
        return mPreferencesApi.getSearchKey();
    }

    /**
     * 保存搜索关键字
     *
     * @param keys
     */
    @Override
    public void saveSearchKey(List<String> keys) {
        mPreferencesApi.saveSearchKey(keys);
    }

    /**
     * 清空历史记录
     */
    @Override
    public void clearHistory() {
        mPreferencesApi.clearHistory();
    }
}
